package org.springblade.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.annotation.PreAuth;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("api")
public class DemoController {
	@GetMapping("info")
	@PreAuth("hasRole('administrator')")
	@Cacheable(cacheNames = "demo-info", key = "#name")
	public R<String> info(String name) {
		log.info("本条信息没有从缓存获取");
		return R.data("Hello, My Name Is: " + name);
	}
}

